package com.minelx.datamicroscope.core.condition;

import com.alibaba.fastjson.JSONObject;
import com.minelx.datamicroscope.core.values.CommonField;

import java.util.List;

public class InOperand implements Operand {
	private final List<String> values;

	InOperand(List<String> values) {
		this.values = values;
	}

	@Override
	public String sqlOf(CommonField key) {
		return key.inCondition(values).toText();
	}

	public List<String> getValues() {
		return values;
	}

	@Override
	public JSONObject toJSON() {
		JSONObject result = new JSONObject();
		result.put("operator", "in");
		result.put("value", values);
		return result;
	}
}
